Passed
Pull Request — master (#72)
by Mathieu
01:35
created

Customer.getAddress   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
1
import {Entity, Column, PrimaryGeneratedColumn, ManyToOne} from 'typeorm';
2
import {Address} from './Address.entity';
3
4
@Entity()
5
export class Customer {
6
  @PrimaryGeneratedColumn('uuid')
7
  private id: string;
8
9
  @Column({type: 'varchar', nullable: false})
10
  private name: string;
11
12
  @Column({type: 'timestamp', default: () => 'CURRENT_TIMESTAMP'})
13
  private createdAt: Date;
14
15
  @ManyToOne(type => Address, {nullable: true})
16
  private address: Address;
17
18
  constructor(name: string, address?: Address) {
19
    this.name = name;
20
    this.address = address;
21
  }
22
23
  public getId(): string {
24
    return this.id;
25
  }
26
27
  public getName(): string {
28
    return this.name;
29
  }
30
31
  public getCreatedAt(): Date {
32
    return this.createdAt;
33
  }
34
35
  public getAddress(): Address {
36
    return this.address;
37
  }
38
39
  public updateName(name: string): void {
40
    this.name = name;
41
  }
42
}
43